<template>
	<div>
		<!-- Hotcities热门城市 -->
		<div class="city-hot">
			<div class="hot-title">热门城市</div>
			<ul class="hot-list">
				<li v-for="(item,index) in hotCities" :key='index' @click="changeCityName(item.name)">
					{{item.name}}
				</li>
			</ul>
		</div>
		<!-- sort字母排序 -->
		<div class="city-sort">
			<div class="sort-title">字母排序</div>
			  <ul class="sort-list">
			   <li v-for="(item,index) in city">{{item.initial}}</li>
			  </ul>
		</div>
		<!-- List城市首字母列表 -->
		<div class="city-list">
			<div>
				<div v-for="(item,index) in city">
				   <div class="list-title">
				    {{item.initial}}
				   </div>
				   <ol class="list-item">
				    <li v-for="(item,index) in item.list">{{item.name}}</li>
				   </ol>
				  </div>
			</div>
		</div>
	</div>
</template>

<script>
	import {mapMutations} from "vuex"
	export default {
		props:['city','hotCities'],
		methods:{
			//当点击changeCityName：1.获取当前被点击的li标签的城市名称2.跳转回首页
			changeCityName(cityName){
				/* console.log(cityName) */
				this.changeCity(cityName)
				this.$router.push('/')
			},
			//调用vuex内Mutations里面的函数changeCity
			...mapMutations(['changeCity'])
		}
	}
</script>

<style scoped>
	/* List城市首字母列表 */
	.city-list{
		width: 100%;
		font-size: 0.28rem;
	}
	.list-title{
		padding: 0.2rem 0.3rem;
		text-align: left;
	}
	.list-item{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.list-item:before{
		content: "";
		position: absolute;
		border-left: 1px solid #ddd;
		border-right: 1px solid #ddd;
		width: 25%;
		height: 100%;
		left: 25%;
	}
	.list-item:after{
		content: "";
		position: absolute;
		border-right: 1px solid #ddd;
		right: 25%;
		width: 0%;/*解决第三列不可点击的效果*/
		height: 100%;
	}
	.list-item li{
		width: 25%;
		height: 0.9rem;/*45px*/
		float: left;
		line-height: 0.9rem;
		border-bottom: 1px solid #ddd;
		position: relative;/*解决第二列不可点击的效果*/
	}
	/*sort字母排序*/
	.city-sort{
		width: 100%;
		font-size: 0.28rem;
	}
	.sort-title{
		padding: 0.2rem 0.3rem;
		text-align: left;
	}
	.sort-list{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.sort-list li{
		width: 16.66%;
		height: 0.9rem;/*45px*/
		float: left;
		line-height: 0.9rem;
	}
	/* Hotcities热门城市 */
	.city-hot{
		width: 100%;
		font-size: 0.28rem;
	}
	.hot-title{
		padding: 0.2rem 0.3rem;
		text-align: left;
	}
	.hot-list{
		background-color: white;
		color: #212121;
		position: relative;
		overflow: hidden;
	}
	.hot-list:before{
		content: "";
		position: absolute;
		border-left: 1px solid #ddd;
		border-right: 1px solid #ddd;
		width: 33.33%;
		height: 100%;
		left: 33.33%;
	}
	.hot-list li{
		width: 33.33%;
		height: 0.9rem;/*45px*/
		float: left;
		line-height: 0.9rem;
		border-bottom: 1px solid #ddd;
		position: relative;
	}
</style>
